package refercese;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

import org.junit.Test;

public class AutoReferenceDemo {

	@Test
	public void test1() {
		// boolean test(T)  =  boolean contains(String)
		Predicate<String> p = "hello world"::contains;
		System.out.println(p.test("llo"));   // "hello world".contains("llo");
		
		// 使用比较广泛
		List<String> list = Arrays.asList("qwrafa","safkjowie","safksaw","afsafaf","o2r2waf");
		// void accept(T t) = System.out(PrintWriter) void println(String)
		list.forEach(System.out::println);
		
		// void accept(T t) = boolean add(E)
		List<String> list2 = new ArrayList<>();
		list.forEach(list2::add);
		System.out.println(list2);
	}
}
